/*
 * Writer.h
 *
 *  Created on: 29.10.2013
 *      Author: ulgish
 */

#ifndef SYNCWRITER_H_
#define SYNCWRITER_H_

#include <pthread.h>
#include <iostream>
#include <stdio.h>
#include <string>
#include <sstream>
#define MAX_LEN_BUF 256

namespace DT {
// TODO !!! добавить буффер
class SycnWriter {
private:
	pthread_mutex_t mutex;
	std::FILE* os;
	void writeString(const std::string& s);
	void writeChar(const char& c);
	void writeInt(const int& i);
	void writeDouble(const double& d);
	void writeCString(const char* s);
	SycnWriter(const SycnWriter& orig);
	SycnWriter& operator=(const SycnWriter& right);
public:
	SycnWriter();
	void reInit(FILE* os);
	void flush();
	SycnWriter& operator<<(const std::string& s);
	SycnWriter& operator<<(const char& s);
	SycnWriter& operator<<(const int& s);
	SycnWriter& operator<<(const double& d);
	SycnWriter& operator<<(const char* s);
	virtual ~SycnWriter();
};

	static SycnWriter writer;
}

#endif /* WRITER_H_ */
